package com.example.demo.lianxi;


import com.sun.org.apache.bcel.internal.generic.RETURN;

import java.util.ArrayList;

public class lianxi {
    public static  void main(String [] args) {
/*        //无任何数据返回，若改为x=5，则会无限制输出big x
        int x = 1;
        while ( x < 10 ) {
            if ( x > 3) {
                System.out.println("big x");
            }
        }
         */

//输出2个small x
 /*       int x = 5;
        while ( x > 1 ) {
            x = x - 1;
            if ( x < 3) {
                System.out.println("small x");
            }
    }*/

        //    y = x - y;//结果：0 0 1 1 2 1 3 2 4 2
        //   y = y + x;//结果：0 0 1 1 2 3 3 6 4 10

      /*      y = y + 2;//结果：0 2 1 4 2 5 3 6 4 7
            if( y > 4 ) {
                y = y - 1;
            }

        }*/

        /*猜数游戏
        GuessGame game = new GuessGame();
        game.startGame();

         */

        /*练习A：输出结果：tape playing   tape recording
        TapeDeck t=new TapeDeck();
        t.canRecord = true;
        t.playTape();
        if (t.canRecord == true) {
            t.recordTape();
        }

         */

        /*练习b：结果：DVD playing DVD recording
        DVDPlayer d = new DVDPlayer();
        d.canRecord = true;
        d.playDVD();
        if (d.canRecord == true) {
            d.recordDVD();
        }

         */

        //--------------数组练习1--------------
/*
        Books [] myBooks = new Books[3];
        int x = 0;
        myBooks[0]=new Books();
        myBooks[1]=new Books();
        myBooks[2]=new Books();
        myBooks[0].title = "The Grapes of Java";
        myBooks[1].title = "The Java Gatsby";
        myBooks[2].title = "The Java Cookbook";
        myBooks[0].author = "bob";
        myBooks[1].author = "sue";
        myBooks[2].author = "ian";
        while (x < 3) {
            System.out.print(myBooks[x].title);
            System.out.print(" by ");
            System.out.println(myBooks[x].author);
            x = x + 1;
        }

 */
        /*--------------数组练习2-------------------------
        结果： bilbo is a good Hobbit name
                frodo is a good Hobbit name
                sam is a good Hobbit name
        Hobbits [] h = new Hobbits[3];
        int z = -1;
        while (z < 2) {
            z = z + 1;
            h[z] = new Hobbits();
            h[z].name = "bilbo";
            if (z == 1) {
                h[z].name = "frodo";
            }
            if (z == 2) {
                h[z].name = "sam";
            }
            System.out.print(h[z].name + " is a ");
            System.out.println("good Hobbit name");
        }

         */

        /*------java传值方式，结果：42 48-------------
        int orig = 42;
        lianxi x= new lianxi ();
        int y=x.go(orig);
        System.out .println(orig+" "+y);

         */

        /*------java传值方式b，结果：1245-------------
        clock c = new clock();
        c.setTime("1245");
        String tod = c.gettime();
        System.out.println("time:" + tod);
    }

         */


        /*--------------结果：2--------------
        InnerClass innerClass=new InnerClass();
        innerClass.value=1;
        transvalve(innerClass);
        System.out.println(innerClass.value);
         */

        /*----------------结果：13 15 x=6-------------
        lianxi o=new lianxi();
        o.go();
         */

/*----------------结果：drift/hoist sail/drift-------------
        Boat b1=new Boat();
        Sailboat b2=new Sailboat();
        RowBoat b3=new RowBoat();
        b2.setLength(32);
        b1.move();
        b2.move();
        b3.move();
*/




}



/*----------------结果：drift/hoist sail/drift-------------
        public static class  Boat{
            private int length;
            public void setLength(int len){
                length=len;
            }
            public int getLength(){
                return length;
            }
            public void move(){
                System.out.println("drift");
            }
        }

        public static class RowBoat extends Boat{
            public void roeTheBoat(){
                System.out.println("stroke natasha");
            }
        }

        public static class Sailboat extends Boat{
            public void move(){
                System.out.println("hoist sail");
            }
        }

 */




    /*----------------结果：13 15 x=6-------------
        public static void go(){
        int y=7;
        for(int x=1;x<8;x++){
            y++;
            System.out.println(x+" "+y);
        if(x>4){
            System.out.println(++y+" ");
        }
        if(y>14){
            System.out.println("x="+x);
            break;
        }}
    }
 */



    /*--------------结果：2--------------
    public static void  transvalve(InnerClass innerClass){
        innerClass.value=2;
        innerClass=new InnerClass();
        innerClass.value=3;
    }
    static  class InnerClass{
        int value;
    }
     */




    /*------java传值方式b，结果：1245-------------
    public static class clock{
        String time;
        void setTime(String t){
            time=t;
        }
        String gettime(){
            return time;
        }
    }

     */

        /*------java传值方式A，结果：42 48-------------
    int go(int arg)

    {
        arg +=arg* 2;
        return arg;
    }

         */

/*--------------数组练习2-------------------------
  public static   class Hobbits {
        String name;
    }
    
 */

        //--------------数组练习1--------------
    /*
    public static class Books {
        String title;
        String author;
    }

     */



        //-----------------------------------

        /*练习b：结果：DVD playing DVD recording
        public static class DVDPlayer{
    boolean canRecord = false;
    void playDVD(){
        System.out.println("DVD playing");
    }
    void recordDVD(){
        System.out.println("DVD recording");
    }}

         */

/*练习A：输出结果：tape playing   tape recording
   public static class TapeDeck {
        boolean canRecord = false;
        void playTape() {
            System.out.println("tape playing");
        }
        void recordTape() {
            System.out.println("tape recording");
        }
    }

 */




        /*猜数游戏
        public static class Player {
            int number = 0; // 􁄲􀔥􀖊􀚦􀺕􁌴
            public void guess() {
                number = (int) (Math.random() * 10);
                System.out.println("I’m guessing "+ number);
            }
        }
    public static class GuessGame {
        Player p1;
        Player p2;
        Player p3;
        public void startGame() {
            p1 = new Player();
            p2 = new Player();
            p3 = new Player();
            int guessp1 = 0;
            int guessp2 = 0;
            int guessp3 = 0;
            boolean p1isRight = false;
            boolean p2isRight = false;
            boolean p3isRight = false;
            int targetNumber = (int) (Math.random() * 10);
            System.out.println("I’m thinking of a number between 0 and 9...");
            while(true) {
                System.out.println("Number to guess is " + targetNumber);
                p1.guess();
                p2.guess();
                p3.guess();
                guessp1 = p1.number;
                System.out.println("Player one guessed " + guessp1);
                guessp2 = p2.number;
                System.out.println("Player two guessed " + guessp2);
                guessp3 = p3.number;
                System.out.println("Player three guessed " + guessp3);
                if (guessp1 == targetNumber) {
                    p1isRight = true;
                }
                if (guessp2 == targetNumber) {
                    p2isRight = true;
                }
                if (guessp3 == targetNumber) {
                    p3isRight = true;
                }
                if (p1isRight || p2isRight || p3isRight) {
                    System.out.println("We have a winner!");
                    System.out.println("Player one got it right? " + p1isRight);
                    System.out.println("Player two got it right? " + p2isRight);
                    System.out.println("Player three got it right? " + p3isRight);
                    System.out.println("Game is over.");
                    break; // 􁆴􁀥􀦳􀺐􀇈􁋐􁊹􁊹􁃗􁃗􁃗􀣍􀣍􀣍
                } else {
// 􀛼􀯁􀖊􀚟􀇈􀻯􁅜􁄲􀥀􁃄􁀰􀶁
                    System.out.println("Players will have to try again.");
                } // if/else􀦳􀦳􀺐􀺐
            } // 􁃗􁃗􀣍􀣍􀦳􀦳􀺐􀺐
        } // 􀝛􀝛􀝆􀝆􀦳􀦳􀺐􀺐
    } // 􀫌􀫌􀦳􀦳􀺐􀺐

         */

}
